package view.chart;

import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JPanel;

/**
 *
 * @author Kevin
 */
public abstract class Chart extends JPanel
{
    private ChartValue[] values;
    
    public Chart(ChartValue[] values)
    {
        super();
        
        this.values = values;
    }

    @Override
    protected void paintComponent(Graphics g)
    {
        super.paintComponent(g);
        
        paintChart((Graphics2D) g);
    }
    
    protected abstract void paintChart(Graphics2D g2d);
    
    public ChartValue[] getValues()
    {
        return values;
    }

    public void setValues(ChartValue[] values)
    {
        this.values = values;
        
        // New chart values have been set; repaint the component
        if (values != null)
            repaint();
    }
}
